package org.poker.model;

import java.io.Serializable;



public class Suit implements Serializable {


    private static final long serialVersionUID = -6775368509927494399L;

    private int suit;

    public final static int OUROS = 1;
    public final static int ESPADAS = 2;
    public final static int COPAS = 3;
    public final static int PAUS = 4;

    private boolean printTxt = false;

    public Suit() {
    }

    public Suit(int naipe) {
	this.suit = naipe;
    }

    public int getNaipe() {
	return this.suit;
    }

    public void setSuit(int naipe) {
	this.suit = naipe;
    }

    public boolean isPrintTxt() {
        return this.printTxt;
    }

    public void setPrintTxt(boolean printTxt) {
        this.printTxt = printTxt;
    }

    public String getColor() {
	return this.suit%2==1?"VERMELHO":"PRETO";
    }

    public boolean isRed() {
	return this.suit%2==1;
    }

    @Override
    public String toString() {
	if(this.suit == OUROS) {
	    return this.printTxt?"" + 'O':"" + '\u2666';
	} else if(this.suit == ESPADAS) {
	    return this.printTxt?"" + 'E':"" + '\u2660';
	} else if(this.suit == COPAS) {
	    return this.printTxt?"" + 'C':"" + '\u2665' ;
	} else if(this.suit ==  PAUS) {
	    return this.printTxt?"" + 'P':"" + '\u2663';
	}
	return "";
    }

    public int compare(Suit naipe1, Suit naipe2) {
	return Integer.valueOf(naipe1.getNaipe()).compareTo(Integer.valueOf(naipe2.getNaipe()));
    }

    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + suit;
	return result;
    }

    @Override
    public boolean equals(Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (getClass() != obj.getClass())
	    return false;
	final Suit other = (Suit) obj;
	if (suit != other.suit)
	    return false;
	return true;
    }
}
